<?php  if (!defined('PATH_HD')) exit('No direct script access allowed');

class IndexControl extends Control{
	
    function __auto(){
        if(!$_SESSION['id']){
            go('http://localhost/cms0121/');
        }
    }

	function index(){
        $db=M('user');
        $userid=$_SESSION['id'];
        $this->assign('uinfo',$db->find($userid));
        $this->display();
    }

    function header(){
    	$this->display();
    }

    function menu(){
    	$this->display();
    }

    function main(){

        $db=M('user');
        $userid=$_SESSION['id'];
        $this->assign('uinfo',$db->find($userid));
        $time=date('Y-m-d H:i:s', time());
        $this->assign('time',$time);
    	$this->display();
    }

    function person(){
        $db=M('user');
        $result=$db->find($_SESSION['id']);
        $this->assign('result',$result);
        $this->display();
    }

    function editperson(){
        $sql="update ".C('DB_PREFIX')."user set 
            username = '$_POST[username]',
            password = md5('$_POST[password]'),
            email = '$_POST[email]',
            qq = '$_POST[qq]' where userid = $_SESSION[id]";
        if(M()->exe($sql)>=0){
            $this->success('修改成功');
        }else{
            $this->error('修改失败，请重试');
        }
    }

    function loginout(){
        session_unset();
        session_destroy();
        go('htitp://localhost/cms0121/');
    } 	
}

?>